/*
 *  seleccionar_marcador_request.cpp
 *  Wilson
 *
 *  Created by Sebastian Orfino on 1/17/12.
 *  Copyright 2012 lbs3. All rights reserved.
 *
 */
#include "VCPlugInHeaders.h"



//stl includes


//sdk includes
#include "IDocument.h"
#include "ErrorUtils.h"
#include "Utils.h"
#include "ILayoutUIUtils.h"

//project includes
#include "seleccionar_marcador_request.h"
#include "marcadores.h"
#include "pugixml.hpp"



using namespace std;
using namespace eventos;


void seleccionar_marcador_request::operator()(const csxs::event::Event * const eventParam)
{
	using namespace pugi;
	IDocument * frontDoc = Utils<ILayoutUIUtils>()->GetFrontDocument();
	if (!frontDoc) return;
	
	payload_ = eventParam->data;
	
	xml_document doc;
	xml_parse_result result = doc.load(eventParam->data);
	
	if (!result) {
		PMString msg(result.description());
		msg.SetTranslatable(kFalse);
		ErrorUtils::PMSetGlobalErrorCode((ErrorCode)result.status,&msg);
		return;
	}
	
	string id_nota = doc.child("payload").child("id").child_value();
	if (id_nota.length()) {
		doc::marcadores documento(::GetUIDRef(frontDoc));
		documento.seleccionar(id_nota);
	}
	
}
